package com.red.exception;

import com.red.result.Result;
import io.jsonwebtoken.ExpiredJwtException;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.NoHandlerFoundException;

import java.nio.file.AccessDeniedException;

@ControllerAdvice
public class GlobalExceptionHandler {
    //404
    @ExceptionHandler(NoHandlerFoundException.class)
    @ResponseBody
    public Result noHandlerFound(){
        return Result.error(404,"访问路径不存在!");
    }

    @ExceptionHandler(ExpiredJwtException.class)
    @ResponseBody
    public Result expiredJwt(){
        return Result.error(401,"Token已过期");
    }

}
